#include<bits/stdc++.h>
using namespace std;
int n,q,x,y,e,b[1000001],o,k,c[1000001],f;
int a[100001];
void chao1(int t,int r) {
	a[t]=r;
	for (int i = 1; i <= n; i++)
		for (int j = i; j>=2; j--)
			if ( a[j] < a[j-1] ) {
				int t = a[j-1];
				a[j-1] = a[j];
				a[j] = t;
				b[a[i]]=j;
				b[a[j]]=i;
			}
	return;
}
int  chao2(int q) {
	int j=b[q];
	return j;
}
int main() {
freopen("sort.in","r",stdin);
freopen("sort.out","w",stdout);
	cin>>n>>q;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		b[a[i]]=i;
	}
	for(int i=1; i<=q; i++) {
		cin>>o;
		if(o==1) {
			cin>>x>>y;
			chao1(x,y);
			 f=i;
		} else {
			cin>>e;
			c[i]=chao2(e);
		}
	}
	for(int i=1; i<=q; i++) {
		if(c[i]&&i<f)cout<<c[i]<<endl;
		if(c[i]&&i>=f)cout<<c[i]-1<<endl;  
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
